<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8" />
    <title>出库数据记录</title>
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all" />
    <link rel="stylesheet" href="//at.alicdn.com/t/font_739294_4v71dzenelg.css" media="all" />
    <link rel="stylesheet" href="../../layuiadmin/layui/css/my.css" media="all" />
</head>

<body>
    <div class="layui-form" style="margin-left:20px;margin-top:15px;margin-bottom:-20px">
        <div class="layui-form-item">
            <label class="layui-form-label">出库日期：</label>
            <div class="layui-inline">
                <input type="text" class="layui-input" id="datetime" autocomplete="off" placeholder="请选择日期" />
            </div>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;医院名称：
            <div class="layui-inline" style="width:300px">
                <select name="hid" id="select" style="width:300px" class="layui-input" lay-search>
            <option value=""></option>
          </select>
            </div>
            <div class="layui-btn-group">
                <button class="layui-btn layui-btn-normal" data-type="reload" id="serch">
            <i class="layui-icon">&#xe615;</i>查询
          </button>
            </div>
        </div>
    </div>
    <table id="demo" lay-filter="test"></table>
    <script src="../../layuiadmin/layui/layui.js"></script>
    <script src="../../layuiadmin/layui/jquery-3.3.1.min.js"></script>
    <script src="../../layuiadmin/layui/action.js"></script>

    <script>
        layui
            .config({
                base: "../../layuiadmin/" //静态资源所在路径
            })
            .extend({
                index: "lib/index" //主入口模块
            })
            .use(["index"]);
        layui.use("laydate", function() {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: "#datetime", //指定元素
                theme: "#1E9FFF"
            });
        });
        var cols = layui.use("laydate", function() {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: "#datetime" //指定元素
            });
        });
        layui.use("table", function() {
            var table = layui.table;
            var $ = layui.$;
            var tableIns = table.render({
                elem: "#demo",
                height: "full-75",
                data: [],
                totalRow: true,
                cols: [
                    [
                        //表头
                        {
                            field: "hospname",
                            title: "医院名称",
                            width: "8%",
                            align: 'center',
                            event: "info"
                        }, {
                            field: "ctime",
                            title: "出库时间",
                            align: 'center',
                            width: "10%"
                        }, {
                            field: "cname",
                            title: "收集人员",
                            align: 'center',
                            width: "8%"
                        }, {
                            field: "sname",
                            title: "出库审核人员",
                            align: 'center',
                            width: "8%",
                            totalRowText: "合计"
                        }, {
                            field: "totalweight",
                            title: "总重量",
                            width: "8%",
                            align: "center",
                            totalRow: true
                        }, {
                            field: "weight_0",
                            title: "感染性重量",
                            width: "8%",
                            align: "center",
                            totalRow: true
                        }, {
                            field: "weight_1",
                            title: "损伤性重量",
                            width: "8%",
                            align: "center",
                            totalRow: true
                        }, {
                            field: "weight_5",
                            title: "病理性重量",
                            width: "8%",
                            align: "center",
                            totalRow: true
                        }, {
                            field: "weight_4",
                            title: "药物性重量",
                            width: "8%",
                            align: "center",
                            totalRow: true
                        }, {
                            field: "weight_3",
                            title: "化学性重量",
                            width: "8%",
                            align: "center",
                            totalRow: true
                        }, {
                            field: "weight_2",
                            title: "输液瓶重量",
                            width: "8%",
                            align: "center",
                            totalRow: true
                        }, {
                            field: "weight_7",
                            title: "输液袋重量",
                            width: "8%",
                            align: "center",
                            totalRow: true
                        }
                    ]
                ],
                skin: "row", //表格风格
                even: true,
                totalRow: true
            });
            $("#serch").on("click", function() {
                tableIns.reload({
                    url: "../../../Collect/UnloadSum",
                    where: {
                        date: $("#datetime").val(),
                        hid: $("#select option:selected").val()
                    } //设定异步数据接口的额外参数
                });
            });
            $.ajax({
                url: "../../../Cust/hospital",
                dataType: "json",
                type: "get",
                success: function(res) {
                    $.each(res.data, function(index) {
                        var id = res.data[index].hid;
                        var name = res.data[index].name;
                        $("#select").append(
                            "<option value='" + id + "'>" + name + "</option>"
                        );
                    });
                    layui.form.render();
                }
            });
        });
    </script>
</body>

</html>